package com.dime.basic.controller;

import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.dime.basic.api.domain.DimeBasemaincheckconclusionadvice;
import com.ruoyi.common.core.domain.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;

import com.dime.basic.service.IDimeBasemaincheckconclusionadviceService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 主检结论对应建议Controller
 *
 * @author Tiny
 * @date 2023-10-11
 */

@RestController
@RequestMapping("/basemaincheckconclusionadvice")
public class DimeBasemaincheckconclusionadviceController extends BaseController
{
    @Autowired
    private IDimeBasemaincheckconclusionadviceService dimeBasemaincheckconclusionadviceService;

    /**
     * 查询主检结论对应建议列表
     */
//    @RequiresPermissions("basic:basemaincheckconclusionadvice:list")
    @GetMapping("/list")
    public TableDataInfo list(DimeBasemaincheckconclusionadvice dimeBasemaincheckconclusionadvice)
    {
        startPage();
        List<DimeBasemaincheckconclusionadvice> list = dimeBasemaincheckconclusionadviceService.selectDimeBasemaincheckconclusionadviceList(dimeBasemaincheckconclusionadvice);
        return getDataTable(list);
    }

    /**
     * 导出主检结论对应建议列表
     */
    @RequiresPermissions("basic:basemaincheckconclusionadvice:export")
    @Log(title = "主检结论对应建议", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DimeBasemaincheckconclusionadvice dimeBasemaincheckconclusionadvice)
    {
        List<DimeBasemaincheckconclusionadvice> list = dimeBasemaincheckconclusionadviceService.selectDimeBasemaincheckconclusionadviceList(dimeBasemaincheckconclusionadvice);
        ExcelUtil<DimeBasemaincheckconclusionadvice> util = new ExcelUtil<DimeBasemaincheckconclusionadvice>(DimeBasemaincheckconclusionadvice.class);
        util.exportExcel(response, list, "主检结论对应建议数据");
    }

    /**
     * 获取主检结论对应建议详细信息
     */
    @RequiresPermissions("basic:basemaincheckconclusionadvice:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(dimeBasemaincheckconclusionadviceService.selectDimeBasemaincheckconclusionadviceById(id));
    }

    /**
     * 新增主检结论对应建议
     */
    @RequiresPermissions("basic:basemaincheckconclusionadvice:add")
    @Log(title = "主检结论对应建议", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DimeBasemaincheckconclusionadvice dimeBasemaincheckconclusionadvice)
    {
        return toAjax(dimeBasemaincheckconclusionadviceService.insertDimeBasemaincheckconclusionadvice(dimeBasemaincheckconclusionadvice));
    }

    /**
     * 修改主检结论对应建议
     */
    @RequiresPermissions("basic:basemaincheckconclusionadvice:edit")
    @Log(title = "主检结论对应建议", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DimeBasemaincheckconclusionadvice dimeBasemaincheckconclusionadvice)
    {
        return toAjax(dimeBasemaincheckconclusionadviceService.updateDimeBasemaincheckconclusionadvice(dimeBasemaincheckconclusionadvice));
    }

    /**
     * 删除主检结论对应建议
     */
    @RequiresPermissions("basic:basemaincheckconclusionadvice:remove")
    @Log(title = "主检结论对应建议", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(dimeBasemaincheckconclusionadviceService.deleteDimeBasemaincheckconclusionadviceByIds(ids));
    }


    @PostMapping(value = "info/getconclusionadviceList")
    public R<List<DimeBasemaincheckconclusionadvice>> getconclusionadviceList(@RequestBody  DimeBasemaincheckconclusionadvice dimeBasemaincheckconclusionadvice)
    {
        List<DimeBasemaincheckconclusionadvice>dimeBasemaincheckconclusionadviceList=dimeBasemaincheckconclusionadviceService.selectDimeBasemaincheckconclusionadviceList(dimeBasemaincheckconclusionadvice);
        return  R.ok(dimeBasemaincheckconclusionadviceList);
    }
}